package top.zuli.package03.exam01;

public abstract class CodeTemplate2 {
    public void spendTime(){
        long start = System.currentTimeMillis();
        this.code();
        long end = System.currentTimeMillis();
        System.out.println("花费的时间为："+(end - start));
    }
    public abstract void code();

    public static void main(String[] args) {
        CodeTemplate2 codeTemplate2 = new SubTemplate2();
        codeTemplate2.spendTime();
    }
}
class SubTemplate2 extends CodeTemplate2{

    @Override
    public void code() {
        int sum  = 0;
        for (int i = 1; i <= 10000 ; i++) {
            sum += i;
        }
        System.out.println(sum);
    }
}
